import Vue from "vue"
import Router from "vue-router"

Vue.use(Router)

import Layout from "@/layout"

export const constantRoutes = [
  {
    path: "/Login",
    component: () => import("@/views/Login/index.vue"),
    hidden: true
  },
  
  {
    path: "/404",
    name: "NotFound",
    component: () => import("@/views/NotFound/index.vue"),
    hidden: true
  },
  
  {
    path: "/",
    component: Layout,
    redirect: "/home",
    children: [
      {
        path: "home",
        name: "Home",
        component: () => import("@/views/Home/index.vue"),
        meta: {
          title: "首页",
          icon: "el-icon-s-home"
        }
      }
    ]
  }
]

export const asyncRoutes = [

]

export const anyRoutes = [
  {
    path: "*",
    redirect: "/404",
    hidden: true
  }
]

const createRouter = () => new Router({
  mode: "history",
  scrollBehavior: () => ({ y: 0 }),
  routes: [...constantRoutes, ...asyncRoutes, ...anyRoutes]
})

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher
}

export default router
